-- BloodAltar
-- Created by chengb Nov/10/2015
-- 鲜血祭坛格子

require "game/ui/form/dungeon/special/UIBloodAltar"

-- 初始化
function initBloodAltar(self)
    self.item:removeAllChildren();

    local function onClicked(sender, eventType)
        if eventType == ccui.TouchEventType.began then
            if self.gridData.state == GRID_STATE_DISABLE then
                -- 已经失效，不处理
                return;
            end

            -- 更新建筑访问
            self:updateBuildingVisit();

            -- 音效
            AudioM.playFx("admix_medal");

            local pos = self.gridData:getPos();

            -- 打开鲜血祭坛界面
            UIMgr.getCurrentScene():removeFormByName("UIBloodAltar");
            local uiForm = UIBloodAltar.create();
            UIMgr.getCurrentScene():addForm(uiForm);
        end
    end

    local iconPath = getLevelItemIconPath("blood_altar");
    self.icon = ccui.ImageView:create(iconPath);
    self.icon:setTouchEnabled(true);
    self.icon:addTouchEventListener(onClicked);
    self.item:addChild(self.icon);
    self.iconPath = iconPath;
    self.item:setPositionY(10);
end
